package com.battcn.platform.mapper.sys;

import com.battcn.framework.mybatis.mapper.BaseMapper;
import com.battcn.platform.pojo.po.sys.Office;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author Levin
 */
@Mapper
public interface OfficeMapper extends BaseMapper<Office> {

    /**
     * 查询所有菜单,根据 scort 升序排序
     *
     * @return 查询结果
     */
    @Select("SELECT * FROM t_sys_office WHERE locked = 1 and del_flag = '0' ORDER BY scort ASC")
    List<Office> listOffice();

    /**
     * 调用 refreshOfficeTreeNodes 存储过程
     */
    @Select("CALL refreshOfficeTreeNodes();")
    void refreshOfficeTreeNodes();

    /**
     * 根据菜单ID删除
     *
     * @param id 菜单ID
     */
    @Update("update t_sys_office set del_flag = '1' WHERE id = #{id}")
    int deleteById(Integer id);
}